package com.example.demo.controller;

import com.example.demo.entity.Comment;
import com.example.demo.mapper.CommentMapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "评论访问接口（废弃）")
@RestController
@RequestMapping("/api/comment")
public class CommentController {
    @Autowired
    private CommentMapper commentmapper;
/*
    @ApiOperation(value = "获取所有评论信息")
    @GetMapping("/info")
    public List selectAll(){
        return commentmapper.selectList(null);
    }

    @ApiOperation(value = "根据评论id获取评论信息")
    @GetMapping("/info/id")
    public Comment selectById(int id)
    {
        return commentmapper.selectById(id);
    }

    @ApiOperation(value = "根据用户id获取评论信息")
    @GetMapping("/info/cid")
    public List selectByCid(int cid)
    {
        return commentmapper.selectByCid(cid);
    }

    @ApiOperation(value = "根据文章id获取评论信息")
    @GetMapping("/info/aid")
    public List selectByAid(int aid)
    {
        return commentmapper.selectByAid(aid);
    }

    @ApiOperation(value = "添加新评论信息")
    @PostMapping("")
    public boolean insert(Comment comment) {
        return commentmapper.insert(comment) > 0;
    }

    @ApiOperation(value = "根据评论id移除旧评论信息")
    @DeleteMapping("/id")
    public boolean deleteById(int id){
        return commentmapper.deleteById(id) > 0;
    }

    @ApiOperation(value = "根据评论文章id移除旧评论信息")
    @DeleteMapping("/aid")
    public boolean deleteByAid(int aid){
        return commentmapper.deleteByAid(aid) > 0;
    }

    @ApiOperation(value = "根据评论id更新评论信息")
    @PutMapping("")
    public boolean updateById(Comment comment){
        return commentmapper.updateById(comment) > 0;
    }*/
}